package com.unswift.map;

import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("serial")
public class CaseInsensitiveMap<V> extends HashMap<String, V>{

	@Override
	public V get(Object key) {
		if(key instanceof String) {
			return super.get(key.toString().toLowerCase());
		}
		return super.get(key);
	}
	
	@Override
	public V put(String key, V value) {
		return super.put(key.toLowerCase(), value);
	}
	
	@Override
	public void putAll(Map<? extends String, ? extends V> m) {
		for (Map.Entry<? extends String, ? extends V> entry : m.entrySet()) {
            put(entry.getKey(), entry.getValue());
        }
	}
	
	@Override
	public boolean containsKey(Object key) {
		if(key instanceof String) {
			return super.containsKey(key.toString().toLowerCase());
		}
		return super.containsKey(key);
	}
}
